package com.zxmr.hospital.info.action;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.zxmr.action.Request;
import com.zxmr.action.Response;
import com.zxmr.action.ResponsePayload;
import com.zxmr.domain.account.User;
import com.zxmr.domain.service.UserService;
import com.zxmr.navigate.Executor;

public class QueryAllEmployeeSimple extends Executor{

	class simpleDTO{
		int id;
		String name;
		public int getId() {
			return id;
		}
		public void setId(int id) {
			this.id = id;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		
		
	}
	@Override
	public void execute(Request request, Response response) {
		
		UserService service = new UserService();
		List<User> es = service.findAllSimpleUserByCompany(request.getAccount().getCompany());
		
		List<simpleDTO> dtos = new ArrayList<simpleDTO>();
		for(User user : es)
		{
			simpleDTO dto = new simpleDTO();
			dto.setId(user.getId());
			dto.setName(user.getName());
			dtos.add(dto);
		}
		ResponsePayload payload = new ResponsePayload();
		
		payload.setValue(JSON.toJSONString(dtos));
		response.setPayload(payload);
	}

}
